<?php
    require_once("condb.php");
    require_once("functions.php");
    
    $output = array();
    $info = isset($_GET["info"]) ? $_GET["info"] : "";
    if(!empty($info)){
        $info = urldecode(base64_decode($info));
        parse_str($info, $request);    
        
        $token = isset($request["token"]) ? cleanQuery($request["token"]) : "";
        if($token=="TAoViEC@)!#2012"){            
                        
            /* Lấy quảng cáo */
            $adv = getAdv();
            if(!empty($adv)){
                $promotion = array();
                $promotion["src"] = getImage($adv["picture"], "banner", $adv["create_date"], "");
                $promotion["link"] = $adv["link"];    
            }
            
            /* Lấy quảng cáo text */
            $advText = getAdvText();
            if(!empty($advText)){
                $promotionText = array();
                $promotionText["title"] = $advText["title"];
                $promotionText["link"] = $advText["link"];    
            }
            
            $output["status"] = 1;
            $output["msg"] = "Success Request"; 
                
        } else {
            $output["status"] = 3;
            $output["msg"] = "Invalid Request";    
        }
    } else {
        $output["status"] = 2;
        $output["msg"] = "Invalid Request";
    }
                
    $output["promotion"] = isset($promotion) ? $promotion : array();
    $output["promotionText"] = isset($promotionText) ? $promotionText : array();
    $output["time"] = (string) date("d/m/Y");
    
    echo json_encode($output);  
?>